package com.yqg.protection.listenern;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.yqg.protection.controller.dto.ImportRecordOperateDto;
import com.yqg.protection.entity.RecordOperate;
import com.yqg.protection.mapper.RecordOperateMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * projectName:xf-service1
 * author:zxf
 * time:2024/10/15 15:21
 * description:
 */
@Component
public class RecordOperateListener extends AnalysisEventListener<ImportRecordOperateDto> {

    @Autowired
    private RecordOperateMapper recordOperateMapper;

    @Override
    public void invoke(ImportRecordOperateDto importRecordOperateDto, AnalysisContext analysisContext) {
        RecordOperate recordOperate = new RecordOperate();
        BeanUtil.copyProperties(importRecordOperateDto, recordOperate, true);
        recordOperate.setIsDelete(0);
        recordOperateMapper.insert(recordOperate);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
